﻿<Page
    x:Name="pageRoot"
    x:Class="Ch9RSS_Universal.SectionPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Ch9RSS_Universal"
    xmlns:data="using:Ch9RSS_Universal.Data"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:convert="using:Ch9RSS_Universal.Converters"
    xmlns:s="using:System"
    xmlns:play="using:Microsoft.PlayerFramework"
    mc:Ignorable="d">

    <Page.Resources>
        <convert:ThumbConverter x:Key="ThumbConverter" />
        <convert:GroupToMediaConverter x:Key="GroupToMedia" />
        <x:Double x:Key="targetSize">240</x:Double>
        </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="361*"/>
            <ColumnDefinition Width="545*"/>
            <ColumnDefinition Width="460*"/>
        </Grid.ColumnDefinitions>
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <!-- Back button and page title -->
        <Grid Grid.ColumnSpan="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Top"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
            <TextBlock x:Name="pageTitle" Text="{Binding SelectedSeries}" 
                        Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,0,40"/>
        </Grid>
        <!-- Horizontal scrolling grid -->
        <ListView
            x:Name="itemGridView"
            AutomationProperties.AutomationId="ItemGridView"
            AutomationProperties.Name="Items In Group"
            TabIndex="1"
            Grid.Row="1"
            Padding="106,0,0,0"
            ItemsSource="{Binding SeriesItems}"
            SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
            SelectionChanged="itemGridView_SelectionChanged"
            Grid.RowSpan="2" >
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="10,10,20,10" Height="210">
                        <Border x:Name="parentBorder" Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" >
                            <Image Source="{Binding thumbnail, Converter={StaticResource ThumbConverter}, ConverterParameter={StaticResource targetSize}}" 
                                   Stretch="UniformToFill" 
                                   AutomationProperties.Name="{Binding Title}" 
                                   />
                        </Border>
                        <StackPanel VerticalAlignment="Bottom" Margin="0,0,0,0" Background="#CCF97600">
                            <TextBlock Text="{Binding title}" Foreground="White" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="Wrap" MaxLines="3" Margin="5,5,5,10" FontSize="14" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
            <ListView.ItemContainerStyle>
                <Style TargetType="FrameworkElement">
                    <Setter Property="Margin" Value="0,0,0,2"/>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>

        <WebView x:Name="itemContentView" 
                     Grid.RowSpan="2" 
                     Grid.Row="1"
                     Grid.Column="2" 
                     Opacity="0"
                     Margin="20,20,20,20" NavigationStarting="PushNavigationToIE"
                     />
        <play:MediaPlayer 
                x:Name="sidePlayer" 
                Grid.Row="1"
                Grid.Column="1"
                Margin="20"
                IsFullScreenVisible="True"
                IsFullScreenChanged="sidePlayer_IsFullScreenChanged" />
        <!-- Source="{Binding SeletedItem.group, Converter={StaticResource GroupToMedia}}" -->
        

    </Grid>
</Page>
